n,k = list(map(int, input().split()))

from math import *

def numlen(n):
  #return ceil(log(n+1) / log(10))
  #ans = 0
  #while n:
  #  ans += 1
  #  n //= 10
  #return ans
  return len(str(n))

global digitlen
digitlen = [0]

#def digitlen(n):
#  lenn = numlen(n)
#  ans = 0
#  for i in range(1,lenn):
#    ans += ((10**(i)) - (10**(i-1))) * i
#  ans += (n - 10**(lenn-1) + 1) * lenn
#  return ans

#def rdl(n):
#  if n = 1:
#    return 1
#  else
#    return 2*rdl(n-1) + numlen(n)

def sol(n,k):
  while 1:
    if (k < 1):
      return -1
#    if k > digitlen[n]:
#      return -1
    if k <= numlen(n):
      return str(n)[int(k)-1]
    if n == 1:
      return -1
    else:
      s = digitlen[n-1]
      if k <= s + numlen(n):
        k -= numlen(n)
      else:
        k -= numlen(n)+s
      n -= 1

for i in range(n+1):
  x = digitlen[-1]*2 + numlen(i+1)
  if x > 10**15:
    x = 10**15 + 1
  digitlen.append(x)

print(sol(n,k))
